import { getInfo,getUserLevelCategory } from '@/api/user'
import {getList} from '@/api/tpl'
import {getMenuList,getGroupCategory,getGroupPowerCategory,getHomeCategory,getClauseCategory} from '@/api/menu'
import {commonGetInfo,getAdvsPosList,getVersionList,getPlugList} from '@/api/common'
import {orderPayStatus,orderTypeStatus,yhqOrderPayStatus,orderType,orderExtendPayStatus,orderRefundStatus,smsPlatform,smsScene,settlementType,storeFlowType,userFlowType,weekList,reserveStatus,wechatReplyType,reserveDeliveryTime,getRankingType,getPaymemtType,getUserType,getPlatformTypeList} from '@/api/config'
import {getHelpCategory,getNewsCategory} from '@/api/cms'
import {getGoodsCategory,getBrandCategory,getGoodsTypeCategory,getShoppingCategory,getAutoDeliveryCategory} from '@/api/goods'
import {getStoreCategory,getStoreList,getStoreMenuList,getStoreGroupList,getStoreConfigList,getStorePowerList} from '@/api/store'
import {getFilmBackgroudCategory,getThemeCategory,getGiftCategory} from '@/api/live'
import {getCategory} from '@/api/reserve'
import {getPlugCategory} from '@/api/plug'


export async function getPlugListText(){
  var list = [];
  var res = await getPlugList({search:{status:1}});
  if(res && res.code == 200) {
    list = res.data.list;
  }
  return Promise.resolve({list:list});
}


export async function getPlugCategoryText(){
  var list = [];
  var res = await getPlugCategory({isTree:1,search:{status:1}});
  if(res && res.code == 200) {
    list = res.data.list;
  }
  return Promise.resolve({list:list});
}


export async function getVersionListText(){
  var list = [];
  var res = await getVersionList({search:{status:1,type:3}});
  if(res && res.code == 200) {
    list = res.data.list;
  }
  return Promise.resolve({list:list});
}


/**
 * 帮助中心分类
 */
export async function getHelpCategoryText(){
  var list = [];
  var res = await getHelpCategory({isTree:1,search:{status:1}});
  if(res && res.code == 200) {
    list = res.data.list;
  }
  return Promise.resolve({list:list});
}

/**
 * 文章分类列表
 */
export async function NewsCategorySelectText(){
  var list = [];
  var res = await getNewsCategory({isTree:1,search:{status:1}});
  //commonGetInfo('/admin/news/category/getCategory',{isTree:1,search:{status:1}});
  if(res && res.code == 200) {
    list = res.data.list;
  }
  return Promise.resolve({list:list});
}

/**
 * 管理员权限数据
 */
export async function GroupMenuSelectText(){
  var list = [];
  var res = await getGroupCategory();
  //commonGetInfo('/admin/admin/group/getMenuList');
  if(res && res.code == 200) {
    list = res.data.list;
  }
  return Promise.resolve({list:list});
}



/**
 * 权限分组
 * @param {*} code
 */
export async function getPowerText(code) {
  var list = [];
  var res = await getGroupPowerCategory();
  //commonGetInfo('/admin/admin/group/getPower');
  if(res && res.code == 200) {
    list = res.data.list;
  }
  console.log(list)
  return Promise.resolve({list:list});
}


/**
 * 前台菜单分类列表
 */
export async function HomeCategorySelectText(){
  var list = [];
  var res = await getHomeCategory({search:{status:1}});
  // commonGetInfo('/admin/member/navCategory/getCategory',{search:{status:1}});
  if(res && res.code == 200) {
    list = res.data.list;
  }
  return Promise.resolve({list:list});
}




export async function ClauseSelectText(){
  var list = [];
  var res = await getClauseCategory({search:{status:1},order:['id','desc']});
  //commonGetInfo('/admin/admin/Clause/getCategory',{search:{status:1},order:['id','desc']});
  if(res && res.code == 200) {
    list = res.data.list;
    list.unshift({id:0,title:'全部项目'})
  }
  return Promise.resolve({list:list});
}




/**
 * 用户等级
 */
export async function UserLevelSelectText(){
  var list = [];
  var res = await getUserLevelCategory({order:['id','desc']});
  //commonGetInfo('/admin/admin/userLevel/getCategory',{order:['id','desc']});
  if(res && res.code == 200) {
    list = res.data.list;
    list.push({id:0,title:'平台管理员'})
  }
  return Promise.resolve({list:list});
}


/**
 * 预约类型列表
 */
export async function getReserveCategoryText(){
  var list = [];
  var res = await getCategory({order:['id','desc']});
  if(res && res.code == 200) {
    list = res.data.list;
  }
  return Promise.resolve({list:list});
}




/**
 * 广告位置列表
 */
export async function AdvsPosSelectText(){
  var list = [];
  var res = await getAdvsPosList({search:{status:1}});
  //commonGetInfo('/admin/marketing/advsPos/getCategory',{search:{status:1}});
  if(res && res.code == 200) {
    list = res.data.list;
  }
  return Promise.resolve({list:list});
}








/**
 * 门店分类
 */
export async function StoreCategorySelectText(){
  var list = [];
  var res = await getStoreCategory({search:{status:1}});
  //commonGetInfo('/admin/store/category/getList',{status:1});
  if(res && res.code == 200) {
    list = res.data.list;
  }
  return Promise.resolve({list:list});
}

/**
 * 门店列表
 */
export async function StoreSelectText(){
  var list = [];
  var res = await getStoreList({search:{status:1}});
  //commonGetInfo('/admin/store/store/getList',{status:1});
  if(res && res.code == 200) {
    list = res.data.list;
    list.unshift({id:0,title:'请选择'});
  }
  
  return Promise.resolve({list:list});
}


/**
 * 门店菜单
 */
export async function StoreMenuSelectText(){
  var tree = [];
  var result = await getStoreMenuList({isTree:1,search:{status:1}});
  //commonGetInfo('/admin/store/menu/getCategory',{isTree:1,search:{status:1}});

  if(result && result.code == 200) {
    tree = result.data.list;
  }
  return Promise.resolve({tree:tree});
}


/**
 * 门店权限
 */
export async function StoreGroupMenuSelectText(){
  var list = [];
  var res = await getStoreGroupList({search:{status:1}});
  //commonGetInfo('/admin/store/group/getMenuList',{search:{status:1}});
  if(res && res.code == 200) {
    list = res.data.list;
  }
  return Promise.resolve({list:list});
}


/**
 * 门店支付配置数据
 */
export async function PayListSelectText(){
  var list = [];
  var res = await getStoreConfigList();
  //commonGetInfo('/admin/store/config/getPayList',{});
  if(res && res.code == 200) {
    list = res.data.list;
  }
  return Promise.resolve({list:list});
}


/**
 * 门店权限分组
 * @param {*} code
 */
export async function getStorePowerText(code) {
  var list = [];
  var res = await getStorePowerList();
  //commonGetInfo('/admin/store/group/getPower');
  if(res && res.code == 200) {
    list = res.data.list;
  }
  
  return Promise.resolve({list:list});
}



/**
 * 综合商城分类
 */
export async function ShopCategorySelectText(){
  var list = [];
  var res = await getGoodsCategory({search:{status:1,type_id:2}});
  //commonGetInfo('/admin/shop/category/getCategory',{search:{status:1,type_id:2}});
  if(res && res.code == 200) {
    list = res.data.list;
  }
  return Promise.resolve({list:list});
}

/**
 * 积分商城分类
 */
export async function JiFenShopCategorySelectText(){
  var list = [];
  var res = await getGoodsCategory({search:{status:1,type_id:3}});
  // commonGetInfo('/admin/shop/scoreCategory/getCategory',{search:{status:1,type_id:3}});
  if(res && res.code == 200) {
    list = res.data.list;
  }
  return Promise.resolve({list:list});
}


/**
 * 商品品牌
 */
export async function ShopBrandSelectText(){
  var list = [];
  var res = await getBrandCategory({search:{status:1}});
  // commonGetInfo('/admin/shop/brand/getCategory',{search:{status:1}});
  if(res && res.code == 200) {
    list = res.data.list;
  }
  return Promise.resolve({list:list});
}


/**
 * 商城类型
 */
export async function ShopTypeelectText(){
  var list = [];
  var res = await getGoodsTypeCategory({search:{status:1},order:['id','desc']});
  // commonGetInfo('/admin/shop/goodsType/getCategory',{search:{status:1},order:['id','desc']});
  if(res && res.code == 200) {
    list = res.data.list;
  }
  return Promise.resolve({list:list});
}

/**
 * 物流模板
 * @param {*} code
 */
export async function getShoppingText(code) {
  var list = [];
  var res = await getShoppingCategory({search:{status:1},order:['id','desc']});
  //commonGetInfo('/admin/shop/shopping/getCategory',{search:{status:1},order:['id','desc']});
  if(res && res.code == 200) {
    list = res.data.list;
    list.unshift({id:0,title:'不需要物流'});
  }
  
  return Promise.resolve({list:list});
}


/**
 * 自动发货分类
 * @param {*} code 
 */
export async function getAutoDeliveryCategoryText(code) {
  var list = [];
  var res = await getAutoDeliveryCategory({status:1,order:['id','desc']});
  //commonGetInfo('/admin/shop/autoDeliveryCategory/getCategory',{status:1,order:['id','desc']});
  if(res && res.code == 200) {
    list = res.data.list;
  }
  
  return Promise.resolve({list:list});
}



/**
 * 页面模板
 */
export async function tplSelectText(){
    var tplList = [];
    var res = await getList({order:['id','desc']});
    if(res && res.code == 200) {
      tplList = res.data.list;
    }
    return Promise.resolve({tplList:tplList});
}

/**
 * 系统菜单
 */
export async function menuSelectText(){
  var tree = [];
  var result = await getMenuList({isTree:1});
  if(result && result.code == 200) {
    tree = result.data.list;
  }
  return Promise.resolve({tree:tree});
}


/**
 * 数据状态
 */
export async function statusAddText() {
  const options = [
    {value:'0',label:'禁用'},
    {value:'1',label:'启用'},
  ];

  return Promise.resolve({list:options});
}


/**
 * 数据状态
 */
export async function TeamText() {
  const options = [
    {value:'1',label:'直推下属'},
    {value:'2',label:'间接下属'},
  ];

  return Promise.resolve({list:options});
}


/**
 * 列表数据状态
 */
export async function statusListText() {
  const options = [
    {value:'0',label:'已禁用'},
    {value:'1',label:'已启用'},
    {value:'2',label:'回收站'},
  ];

  return Promise.resolve({list:options});
}

/**
 * 系统菜单数据分类
 * @param {*} code
 */
export async function menuRoleAddText(code) {

  const options = [
    {id:0,title:'内部菜单'},
    {id:1,title:'会员菜单'},
    {id:2,title:'免费菜单'},
  ];

  return Promise.resolve({list:options});
}


/**
 * 角色类型
 * @param {*} code
 */
export async function roleText(code) {
  const options = [
    {id:1,title:'内部人员'},
    {id:2,title:'外部超级管理员'},
    {id:3,title:'超级管理员'},
    {id:4,title:'外部管理员'},
  ];

  return Promise.resolve({list:options});
}


/**
 * 审核状态
 * @param {*} code
 */
export async function authAddText(code) {
  const options = [
    {id:'0',title:'未审核'},
    {id:'1',title:'审核通过'},
    {id:'2',title:'审核失败'},
  ];

  return Promise.resolve({list:options});
}


/**
 * 审核状态
 * @param {*} code
 */
export async function authListText(code) {
  const options = [
    {id:'0',title:'未审核'},
    {id:'1',title:'已审核'},
    {id:'2',title:'已反审'},
  ];

  return Promise.resolve({list:options});
}





/**
 * 支付状态
 * @param {*} code
 */
export async function getPayStatusText(code) {
  var options = [];
  var res = await orderPayStatus();
  if(res && res.code == 200) {
    options = res.data.list;
  }

  return Promise.resolve({list:options});
}



/**
 * 支付状态
 * @param {*} code
 */
export async function getPayTypeText(code) {
  var options = [];
  var res = await orderTypeStatus();
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}


/**
 * 液化气支付状态
 * @param {*} code
 */
export async function getYhqPayStatusText(code) {
  var options = [];
  var res = await yhqOrderPayStatus();
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}

/**
 * 支付状态
 * @param {*} code
 */
export async function getOrderTypeText(code) {
  var options = [];
  var res = await orderType();
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}


/**
 * 支付状态
 * @param {*} code
 */
export async function getDetailPayStatusText(code) {
  var options = [];
  var res = await orderExtendPayStatus();
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}

/**
 * 退款
 * @param {*} code 
 */
export async function getRefundStatusText(code) {
  var options = [];
  var res = await orderRefundStatus();
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}


/**
 * 使用场景
 * @param {*} code 
 */
export async function getSceneText(code) {
  const options = [
    {id:'0',title:'全局使用'},
    {id:'1',title:'液化气商城'},
    {id:'2',title:'生活商城'},
  ];

  return Promise.resolve({list:options});
}







/**
 * 短信使用场景
 * @param {*} code 
 */
export async function getSmsSceneText(code) {
  var options = [];
  var res = await smsScene();
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}



/**
 * 短信平台
 * @param {*} code 
 */
export async function getSmsPlatformText(code) {
  var options = [];
  var res = await smsPlatform();
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}


/**
 * 结算类型
 * @param {*} code 
 */
export async function settlementTypeText(code) {
  var options = [];
  var res = await settlementType();
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}



/**
 * 商家流水类型
 * @param {*} code 
 */
export async function storeFlowTypeText(code) {
  var options = [];
  var res = await storeFlowType();
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}



/**
 * 商家流水类型
 * @param {*} code 
 */
export async function userFlowTypeText(code) {
  var options = [];
  var res = await userFlowType();
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}



/**
 * 一周文本配置
 * @param {*} code 
 */
export async function weekListText(code) {
  var options = [];
  var res = await weekList();
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}

/**
 * 预约订单状态
 * @param {*} code 
 */
export async function reserveStatusText(code) {
  var options = [];
  var res = await reserveStatus();
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}


/**
 * 公众号回复类型
 * @param {*} code 
 */
export async function wechatReplyTypeText(code) {
  var options = [];
  var res = await wechatReplyType();
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}


/**
 * 预约送达筛选时间
 * @param {*} code 
 */
export async function reserveDeliveryTimeText(code) {
  var options = [];
  var res = await reserveDeliveryTime();
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}



/**
 * 背景分类
 * @param {*} code 
 */
export async function getFilmBackgroudCategoryText(code) {
  var options = [];
  var res = await getFilmBackgroudCategory({search:{type_id:551}});
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}

export async function getSongBackgroudCategoryText(code) {
  var options = [];
  var res = await getFilmBackgroudCategory({search:{type_id:552}});
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}


/**
 * 主题分类
 * @param {*} code 
 */
export async function getThemeCategoryText(code) {
  var options = [];
  var res = await getThemeCategory({type_id:524});
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}


/**
 * 礼物分类
 * @param {*} code 
 */
export async function getGiftCategoryText(code) {
  var options = [];
  var res = await getGiftCategory();
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}


/**
 * 礼物分类
 * @param {*} code 
 */
export async function getRankingTypeText(code) {
  var options = [];
  var res = await getRankingType();
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}


export async function getPaymemtTypeText(code) {
  var options = [];
  var res = await getPaymemtType();
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}

export async function getUserTypeText(code) {
  var options = [];
  var res = await getUserType();
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}



export async function getPlatformTypeListText(code) {
  var options = [];
  var res = await getPlatformTypeList();
  if(res && res.code == 200) {
    options = res.data.list;
  }
  return Promise.resolve({list:options});
}



export async function load(code) {
  const options = [
    {
      id: '1',
      title: '选项1123',
      value: '1',
      parentId: null
    },
    {
      id: '2',
      title: '选项2123',
      value: '2',
      parentId: null
    },
    {
      id: '3',
      title: '选项1-1',
      value: '1-1',
      parentId: '1'
    },
    {
      id: '4',
      title: '选项1-2',
      value: '1-2',
      parentId: '1'
    },
    {
      id: '5',
      title: '选项2-1',
      value: '2-1',
      parentId: '2'
    }
  ]
  return Promise.resolve({list:options});
}



export async function load2(code) {
  const res = await getInfo()
  return res.data;
}
